# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from decimal import Decimal
from typing import Union
from fastapi import Query
from pydantic import BaseModel, Field


class SubscribeSearchIn(BaseModel):
    """ 订阅记录搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, le=200, description="每页条数")
    user: Union[str, None] = Query(default=None, description="用户信息")
    order_sn: Union[str, None] = Query(default=None, description="订阅单号")
    pay_way: Union[str, int, None] = Query(default=None, description="支付方式: [2=微信, 3=支付宝]")
    source_client: Union[str, int, None] = Query(default=None, description="来源平台: [1=用, 2=后台]")
    start_time: Union[int, str, None] = Query(default=None, description="开始时间")
    end_time: Union[int, str, None] = Query(default=None, description="结束时间")


class SubscribeRefundIn(BaseModel):
    """ 订阅退款参数 """
    id: int = Field(..., ge=0, description="订单ID")


"""--------------- Separator ---------------"""


class SubscribeListVo(BaseModel):
    """ 订阅记录列表Vo """
    id: int = Field(description="订单ID")
    order_sn: str = Field(description="订阅单号")
    pay_way: str = Field(description="支付方式: [2=微信支付, 2=支付宝支付]")
    pay_status: int = Field(description="支付状态: [0=未支付, 1=已支付]")
    refund_status: int = Field(description="退款状态: [0=未退款, 1=退款中, 2=退款成功, 3=退款失败]")
    source_client: int = Field(description="来源平台: [1=用,2=后台]")
    paid_amount: Decimal = Field(description="实付金额")
    package_name: str = Field(description="套餐名称")
    give_points: int = Field(description="赠送积分")
    calendar: str = Field(description="订阅类型")
    duration: int = Field(description="订阅时长")
    pay_time: str = Field(description="支付时间")
    create_time: str = Field(description="创建时间")
    package_end_time: str = Field(description="到期时间")
    user: dict = Field(description="用户信息")
    pack: dict = Field(description="套餐信息")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "order_sn": "20250106115056292368",
                "pay_way": "微信支付",
                "pay_status": 0,
                "refund_status": 0,
                "source_client": 1,
                "paid_amount": 19.88,
                "package_name": "专业版",
                "give_points": 300,
                "calendar": "month",
                "duration": 1,
                "pay_time": "-",
                "create_time": "2025-01-06 11:50:56",
                "package_end_time": "-",
                "user": {
                    "sn": "80965941",
                    "avatar": "https://xxx.com/image/aa.png",
                    "nickname": "小明",
                    "mobile": "13800138000"
                },
                "pack": {
                    "name": "专业版",
                    "description": "适合专业团队和组织提供对外服务",
                    "train_num": 40000,
                    "robot_num": 200,
                    "know_num": 100,
                    "calendar": "month",
                    "duration": 1,
                    "give_points": 300
                }
            }
        }
